package cn.sise.edu.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class Customer {
    public static final int GENDER_FEMALE   = 0; // 女
    public static final int GENDER_MALE     = 1; // 男

    public static final int STATUS_POTENTIAL = 0;  // 潜在
    public static final int STATUS_FORMAL    = 1;  // 正式
    public static final int STATUS_POOL      = 2;  // 资源池
    public static final int STATUS_FAILURE   = 3;  // 失败
    public static final int STATUS_LOST      = 4;  // 流失

    private Long id;
    private String name;
    private Integer age;
    private Integer gender;
    private String tel;
    private String qq;
    private SystemDictionaryItem job;
    private SystemDictionaryItem source;
    private Employee seller;
    private Employee inputUser;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;
    private int status;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date positiveTime;

    public String getGenderName(){
        if (GENDER_FEMALE==gender){
            return "女";
        }else if(GENDER_MALE ==gender){
            return "男";
        }
            return "尚没有";

    }

    public String getStatusName(){
        if (STATUS_POTENTIAL == status){
            return "潜在";
        }else if(STATUS_FORMAL == status){
            return "正式";
        }else if(STATUS_POOL == status){
            return "资源池";
        }else if(STATUS_FAILURE == status){
            return "失败";
        }else if(STATUS_LOST == status){
            return "流失";
        }
        return "我";
    }

    public String getJsonData(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",this.id);
        map.put("name",this.name);
        map.put("age",this.age);
        map.put("gender",this.gender);
        map.put("tel",this.tel);
        map.put("jobId",this.job.getId());
        map.put("qq",this.qq);
        map.put("sourceId",this.source.getId());
        map.put("sellerId",this.seller.getId());
        return JSON.toJSONString(map);
    }

}